<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		#include("common/header.html")
		<link type="text/css" rel="stylesheet" href="/css/jingdongka.css" />
		<title></title>
	</head>
	<body>
		<header style="background: #005aab;" class="mui-bar mui-bar-nav head">
			<!--<span class="mui-icon mui-icon-back"></span>-->
			<h1 style="color: #FFFFFF; letter-spacing: 4px;" class="mui-title">京东卡兑换</h1>
			<!--<span class="mui-icon mui-icon-more"></span>-->
		</header>
		<nav style="background: #cccccc;" id="bottomx" class="mui-bar mui-bar-tab">
			<a class="mui-tab-item" href="/business/">
				<span class="mui-icon iconfont icon-qiyedengji-copy"></span><br>
				<span class="mui-tab-label">业绩登记</span>
			</a>
			<a class="mui-tab-item mui-active" href="/integral/">
				<span class="mui-icon iconfont icon-icon18"></span><br>
				<span class="mui-tab-label">积分兑换</span>
			</a>
			<a class="mui-tab-item" href="/v/center">
				<span class="mui-icon iconfont icon-gerenzhongxin"></span><br>
				<span class="mui-tab-label">个人中心</span>
			</a>
		</nav>
		<input type="hidden" id="uid" value="${uid}" />
		<div class="mui-content">
			#foreach($item in $data)
			<div class="contains_one">
				<div class="contains_one_img">
					<img src="/img/jingdong.png" /><br />
					<!--<span>京东卡经典卡50面值（电子卡）</span>-->
				</div>
				<span class="spt1">$item.integral积分</span>
				<span onclick="exchange($item.integral)" style="background: #ff6600; color: #FFFFFF;font-size: 8px; border-radius: 2px;">立即兑换</span>
			</div>
			#end
		</div>
	</body>
	<script>
		mui.init();
		nav_tab();


        function exchange(integral) {

            var message = "是否确定兑换" + integral + "面值京东卡!";
            var title = "提示";

            mui.confirm(message,title,null,function (e) {

                if(e.index == 1) {

                    var uid = $("#uid").val();
                    var content = "兑换"+ integral + "面值京东卡";

                    mui.ajax('/integral/exchange', {
                        data: {
                            uid: uid,
                            content: content,
                            integral: integral
                        },
                        dataType: 'json',//服务器返回json格式数据
                        type: 'post',//HTTP请求类型
                        timeout: 10000,//超时时间设置为10秒；
                        success: function (data) {
                            //服务器返回响应，根据响应结果，分析是否登录成功；
                            console.log(data);
                            if (data.code == -1) {
                                mui.toast(data.msg);
                                return;
                            }

                            mui.toast('兑换成功!');
                        },
                        error: function (xhr, type, errorThrown) {
                            //异常处理；
                            console.log(type);
                            mui.toast('请求异常,请稍后重试!');
                        }
                    });
                }
            });


        }

	</script>
</html>
